package util;

import static org.junit.Assert.*;

import java.util.Calendar;
import java.util.GregorianCalendar;

import org.junit.Test;

import entity.*;
import entity.TimeZoneIdentifier;

/**
 * JUNIT Testing File
 * 
 * @author Elliot Ito
 * @version 0.7
 * 
 * */



public class JUNITtesting {

        /**
         * Testing if timeZoneID constructor finds the correct local time zone
         */
        @Test
        public void timeZoneID() {
                TimeZoneIdentifier tZID = new TimeZoneIdentifier();
                assertEquals("Time Zone is correct", "TZID:Pacific/Honolulu\r\n" , tZID.toString());
        }
        
        /**
         * Testing setTzid method in timeZoneID 
         */
        @Test
        public void setTzid() {
                TimeZoneIdentifier tZID = new TimeZoneIdentifier();
                tZID.setTzid("test");
                assertEquals("Time Zone is modified", "TZID:test\r\n" , tZID.toString());
                
        }
        
        /**
         * Testing Summary constructor 
         */
        @Test
        public void summary() {
                Summary sum = new Summary("Test");
                assertEquals("Summary is correct", "SUMMARY:Test\r\n" , sum.toString());
        }
        
        
        /**
         * Testing Summary overloaded constructor
         */
        @Test
        public void summary2() {
                Summary sum = new Summary("test");
                assertEquals("Time Zone is modified", "SUMMARY:test\r\n" , sum.toString());
        }
        
        /**
         * Testing setSummary method in Summary
         */
        @Test
        public void setSummary() {
                Summary sum = new Summary("test");
                sum.setSummary("test2");
                assertEquals("Time Zone is modified", "SUMMARY:test2\r\n" , sum.toString());
        }
        
        /**
         * Testing Classification constructor
         */
        @Test
        public void classification() {
                Classification clas = new Classification();
                assertEquals("Classification is correct","CLASS:PUBLIC\r\n",clas.toString());
        }

        /**
         * Testing Classification overloaded constructor
         */
        @Test
        public void classification2() {
                Classification clas = new Classification(2);
                assertEquals("Classification is correct","CLASS:PRIVATE\r\n",clas.toString());
        }
        
        /**
         * Testing Classification constructor -ERROR CHECK- 
         */
        @Test
        public void classification3() {
                Classification clas = new Classification(5);
                assertEquals("Classification is correct","CLASS:PUBLIC\r\n",clas.toString());
        }
        
        /**
         * Testing setClassValue in Classification
         */
        @Test
        public void setClassValue() {
                Classification clas = new Classification(2);
                clas.setClassValue(3);
                assertEquals("Classification is correct","CLASS:CONFIDENTIAL\r\n",clas.toString());
        }
        
        /**
         * Testing setClassValue -ERROR CHECK- in Classification
         */
        @Test
        public void setClassValue2() {
                Classification clas = new Classification(2);
                clas.setClassValue(5);
                assertEquals("Classification is correct","CLASS:PUBLIC\r\n",clas.toString());
        }
        
        
        /**
         * Testing Priority constructor 
         */
        @Test
        public void priority() {
                Priority priority = new Priority();
                assertEquals("Priority is correct","PRIORITY:0\r\n",priority.toString());
        }

        /**
         * Testing Priority overloaded constructor 
         */
        @Test
        public void priority2() {
                Priority priority = new Priority(2);
                assertEquals("Priority is correct","PRIORITY:2\r\n",priority.toString());
        }
        
        /**
         * Testing Priority overloaded constructor -ERROR CHECK-
         */
        @Test
        public void priority3() {
                Priority priority = new Priority(100);
                assertEquals("Priority is correct","PRIORITY:100\r\n",priority.toString());
        }
        
        /**
         * Testing setPriority method in Priority
         */
        @Test
        public void setPriority() {
                Priority priority = new Priority(100);
                priority.setPriority(-1);
                assertEquals("Priority is correct","PRIORITY:-1\r\n",priority.toString());
        }
        
        /**
         * Testing DateTimeStart constructor
         */
        @Test
        public void DateTimeStart() {
                DateTimeStart dtStart = new DateTimeStart();
                assertEquals("DTStart is correct",null,dtStart.toString());
        }
        
        /**
         * Testing setStartDate in DateTimeStart
         */
        @Test
        public void setStartDate() {
                DateTimeStart dtStart = new DateTimeStart();
                GregorianCalendar start = new GregorianCalendar(2014, Calendar.MAY, 30, 24, 0);
                dtStart.setStartDate(start.getTime());
                assertEquals("DTStart is correct", "DTSTART:20140531T100000Z\r\n",dtStart.toString());
        }
        
        /**
         * Testing DateTimeEnd constructor
         */
        @Test
        public void DateTimeEnd() {
                DateTimeEnd dtEnd = new DateTimeEnd();
                assertEquals("dtEnd is correct",null,dtEnd.toString());
        }
        
        /**
         * Testing setEndDate in DateTimeEnd
         */
        @Test
        public void setEndDate() {
        				DateTimeEnd dtEnd = new DateTimeEnd();
                GregorianCalendar start = new GregorianCalendar(2014, Calendar.MAY, 30, 24, 0);
                dtEnd.setEndDate(start.getTime());
                assertEquals("DTEnd is correct", "DTEND:20140531T100000Z\r\n",dtEnd.toString());
        }

        /**
         * Testing Version constructor
         */
        @Test
        public void Version() {
        				Version testVersion = new Version();
                assertEquals("Version is correct",null,testVersion.toString());
        }
        
        /**
         * Testing Version overloaded constructor
         */
        @Test
        public void Version2() {
        				Version testVersion = new Version("2.0");
                assertEquals("Version is correct","VERSION:2.0\r\n",testVersion.toString());
        }
        
        /**
         * Testing setVerValue in Version
         */
        @Test
        public void setVerValue() {
        				Version testVersion = new Version();
                testVersion.setVerValue("1.0");
                assertEquals("Editing Version is correct", "VERSION:1.0\r\n",testVersion.toString());
        }
        
        /**
         * Testing GeographicPosition constructor
         */
        @Test
        public void GP() {
        				GeographicPosition testGP = new GeographicPosition();
                assertEquals("GEO is correct","GEO:0.0;0.0\r\n",testGP.toString());
        }
        
        /**
         * Testing GeographicPosition overloaded constructor
         */
        @Test
        public void GP2() {
        				GeographicPosition testGP = new GeographicPosition((float)1.0,(float)2.0);
                assertEquals("GEO is correct","GEO:1.0;2.0\r\n",testGP.toString());
        }
        
        /**
         * Testing setLatitude in GeographicPosition
         */
        @Test
        public void setLatitude() {
        				GeographicPosition testGP = new GeographicPosition((float)1.0,(float)2.0);
        				testGP.setLatitude((float)156.0);
                assertEquals("Editing Latitude is correct", "GEO:156.0;2.0\r\n",testGP.toString());
        }
        
        /**
         * Testing setLatitude in GeographicPosition
         */
        @Test
        public void setLongitude() {
        				Version testVersion = new Version();
                testVersion.setVerValue("1.0");
                assertEquals("Editing Version is correct", "VERSION:1.0\r\n",testVersion.toString());
        }
        
        
        
}